<html>

<head>
<title>Selenium Log Console</title>
<link id="cssLink" rel="stylesheet" href="selenium.css" />
<script src="scripts/htmlutils.js"></script>
<script language="JavaScript">

var disabled = true;

function logOnLoad() {
    var urlConfig = new URLConfiguration();
    urlConfig.queryString = window.location.search.substr(1);
    var startingThreshold = urlConfig._getQueryParameter("startingThreshold");
    setThresholdLevel(startingThreshold);
    var buttons = document.getElementsByTagName("input");
    for (var i = 0; i < buttons.length; i++) {
        addChangeListener(buttons[i]);
    }
}

function enableButtons() {
    var buttons = document.getElementsByTagName("input");
    for (var i = 0; i < buttons.length; i++) {
        buttons[i].disabled = false;
        disabled = false;
    }
}

function callBack() {}

function changeHandler() {
    callBack(getThresholdLevel());
}

function addChangeListener(element) {
    if (window.addEventListener && !window.opera)
        element.addEventListener("click", changeHandler, true);
    else if (window.attachEvent)
        element.attachEvent("onclick", changeHandler);
}

var logLevels = {
    debug: 0,
    info: 1,
    warn: 2,
    error: 3
};

function getThresholdLevel() {
    var buttons = document.getElementById('logLevelChooser').level;
    for (var i = 0; i < buttons.length; i++) {
        if (buttons[i].checked) {
            return buttons[i].value;
        }
    }
}

function setThresholdLevel(logLevel) {
    var buttons = document.getElementById('logLevelChooser').level;
    for (var i = 0; i < buttons.length; i++) {
        if (buttons[i].value==logLevel) {
            buttons[i].checked = true;
        }
        else {
            buttons[i].checked = false;
        }
    }
}

function append(message, logLevel) {
    var logLevelThreshold = getThresholdLevel();
    if (logLevels[logLevel] < logLevels[logLevelThreshold]) {
        return;
    }
    var log = document.getElementById('log');
    var newEntry = document.createElement('li');
    newEntry.className = logLevel;
    newEntry.appendChild(document.createTextNode(message));
    log.appendChild(newEntry);
    if (newEntry.scrollIntoView) {
        newEntry.scrollIntoView();
    }
}

</script>
</head>
<body id="logging-console" onload="logOnLoad();">



<div id="banner">
  <form id="logLevelChooser">
      <input id="level-error" type="radio" name="level" disabled='true'
             value="error" /><label for="level-error">Error</label>
      <input id="level-warn" type="radio" name="level" disabled='true'
             value="warn" /><label for="level-warn">Warn</label>
      <input id="level-info" type="radio" name="level" disabled='true'
             value="info" /><label for="level-info">Info</label>
      <input id="level-debug" type="radio" name="level" checked="yes" disabled='true'
             value="debug" /><label for="level-debug">Debug</label>
  </form>
  <h1>Selenium Log Console</h1>
</div>

<ul id="log"></ul>

</body>
</html>
